{% load static %}
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>投票结果 - {{ question.question_text }}</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #3498db;
            --background: #f8f9fa;
        }

        body {
            font-family: 'Segoe UI', system-ui;
            line-height: 1.6;
            max-width: 800px;
            margin: 2rem auto;
            padding: 1rem;
            background: var(--background);
        }

        .results-container {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            padding: 2rem;
        }

        h1 {
            color: var(--primary-color);
            font-size: 2.2rem;
            margin-bottom: 2rem;
            border-bottom: 3px solid var(--secondary-color);
            padding-bottom: 1rem;
        }

        .result-item {
            display: flex;
            align-items: center;
            margin: 1.2rem 0;
            padding: 1rem;
            background: #fff;
            border-radius: 8px;
            transition: transform 0.2s;
            border: 1px solid #eee;
        }

        .result-item:hover {
            transform: translateX(5px);
            box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
        }

        .progress-bar {
            flex-grow: 1;
            height: 12px;
            background: #eee;
            border-radius: 6px;
            margin: 0 1.5rem;
            overflow: hidden;
        }

        .progress-fill {
            height: 100%;
            background: var(--secondary-color);
            border-radius: 6px;
            transition: width 0.5s ease-in-out;
        }

        .vote-count {
            font-weight: 600;
            color: var(--primary-color);
            min-width: 100px;
            text-align: right;
        }

        .vote-again {
            display: inline-flex;
            align-items: center;
            padding: 0.8rem 1.5rem;
            background: var(--secondary-color);
            color: white;
            border-radius: 25px;
            text-decoration: none;
            margin-top: 2rem;
            transition: background 0.3s;
        }

        .vote-again:hover {
            background: #2980b9;
        }

        .vote-again i {
            margin-right: 0.5rem;
        }
    </style>
</head>
<body>
    <div class="results-container">
        <h1>{{ question.question_text }}</h1>

        {% for choice in question.choice_set.all %}
        <div class="result-item">
            <span class="choice-text">{{ choice.choice_text }}</span>

            <div class="progress-bar">
                <div class="progress-fill"
                     style="width: {% widthratio choice.votes total_votes 100 %}%"></div>
            </div>

            <div class="vote-count">
                {{ choice.votes }} 票
                <span class="percentage">({% widthratio choice.votes total_votes 100 %}%)</span>
            </div>
        </div>
        {% endfor %}

        <a href="{% url 'polls:detail' question.id %}" class="vote-again">
            <i class="fas fa-redo-alt"></i>
            重新投票 / Vote Again
        </a>
    </div>
</body>
</html>